*******************************************************************************
******************************  TABLE A12  ************************************
******  Who Received Influence Votes in Groups with a Female Leader?  *********
*******************************************************************************
clear all
set more off

//cd "C:/Users/ganth/Dropbox/StrengthInNumbersReplicationPackage/replicable/table_a12"

//ssc install outreg2, replace

********************************************************************************

**Study 2 Analysis
*Task 2 Female Leader
use "table_a12_dataset.dta", clear

//top panel
qui reg leaderminfl_ratio_r2 i.condition_2f if fem_leader == 1, robust
margins condition_2f, post
matrix votes_fem = e(b)
matrix list votes_fem
	
qui reg genderminfl_ratio_r2 i.condition_2f if fem_leader == 1, robust
margins condition_2f, post
matrix votes_fem_total = e(b)
matrix list votes_fem_total

scalar most_infl_fem_maj_female = round(votes_fem[1,1] / votes_fem_total[1,1], 0.01)
scalar most_infl_fem_maj_male = round(votes_fem[1,2] / votes_fem_total[1,2], 0.01)

matrix votes_fem_other = votes_fem_total - votes_fem
scalar most_infl_fem_other_maj_female = votes_fem_other[1,1] / votes_fem_total[1,1]
local mostinfl_fem_other_majfem_round : di %5.2f most_infl_fem_other_maj_female
scalar most_infl_fem_other_maj_male = round(votes_fem_other[1,2] / votes_fem_total[1,2], 0.01)


//bottom panel
qui reg leaderspokes_ratio_r2 i.condition_2f if fem_leader == 1, robust
margins condition_2f, post
matrix votes_leader = e(b)
matrix list votes_leader

qui reg genderspokes_ratio_r2 i.condition_2f if fem_leader == 1, robust
margins condition_2f, post
matrix votes_leader_total = e(b)
matrix list votes_leader_total

scalar most_infl_leader_maj_female = round(votes_leader[1,1] / votes_leader_total[1,1], 0.01)
scalar most_infl_leader_maj_male = round(votes_leader[1,2] / votes_leader_total[1,2], 0.01)

matrix votes_leader_other = votes_leader_total - votes_leader
scalar most_infl_lead_other_majfem = votes_leader_other[1,1] / votes_leader_total[1,1]
local mostinfl_lead_other_majfem_rd : di %5.2f most_infl_lead_other_majfem
scalar most_infl_lead_other_majmal = votes_leader_other[1,2] / votes_leader_total[1,2]
local mostinfl_lead_other_majmal_rd : di %5.2f most_infl_lead_other_majmal


file open tex_content using table_a12.txt, text write replace
file write tex_content "{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{tabular}{p{0.35\textwidth}*{2}c}\hline\hline&\multicolumn{2}{c}{\textit{Proportion of Votes Received by}} \\& Leader & Other Women\\ \textbf{Most Influential Votes} & & \\ Majority Male & 0`=most_infl_fem_maj_male'  & 0`=most_infl_fem_other_maj_male' \\ Majority Female & 0`=most_infl_fem_maj_female' & `mostinfl_fem_other_majfem_round' \\ & & \\ \textbf{Spokesperson Votes} & & \\ Majority Male & 0`=most_infl_leader_maj_male' & `mostinfl_lead_other_majmal_rd' \\ Majority Female & 0`=most_infl_leader_maj_female' & `mostinfl_lead_other_majfem_rd' \\ \hline\hline \multicolumn{3}{l}{\footnotesize \begin{minipage}{.73\textwidth} \footnotesize \smallskip \textbf{Note:} Cell entries represent the proportion of influence or spokesperson votes received by the woman randomly chosen as the group's leader and by other women in the group. Study 2 only. \end{minipage}}\\ \end{tabular} }" 
file close tex_content



